import { Component, OnInit } from '@angular/core';
import { HeroService } from '../../../../services/hero.service';
import { NzMessageService,NzModalService } from 'ng-zorro-antd';

@Component({
  selector: 'app-feedback',
  templateUrl: './feedback.component.html',
  styleUrls: ['./feedback.component.css']
})
export class FeedbackComponent implements OnInit {
  
  btn_loading=false;
  public feedabckType:string = "2";
  public mobile:string;
  public inputValue:string;
  public mobileCode:number;
  public feedbackCode:number;

  constructor(private heroService: HeroService,
              private message: NzMessageService,
              private modalService: NzModalService) { }

  ngOnInit() {
  }
// 提交反馈
  feedBack(): void {
    if(!this.mobile){
      this.mobileCode = -1;
    }
    if(!this.inputValue){
      this.feedbackCode = -1;
    }
    if(this.mobile && this.inputValue){
      this.btn_loading=true;
      let url=host+"/main/util/feedback";
      let model='type='+this.feedabckType + '&contact='+this.mobile + '&details='+this.inputValue;
      this.heroService.post(url,model).then(result=>{
          this.btn_loading=false;
          if(result.code==0){
            this.message.success('反馈成功！');
          }else{
            this.modalService.error({
              nzTitle: '提示',
              nzContent: result.msg
            });
          }
      })
    }
  }
  onFocusMobile(){
    this.mobileCode = 0;
  }
  onFocusValue(){
    this.feedbackCode = 0;
  }

}
